package sumit;

import java.util.Scanner;

public class JavaConstructs {
	
	int id;
	String name;
	
	
	public void setUp(int id, String name)
	{
		this.id = id;
		this.name=name;
		
	}
	
	
	public static void main(String[] args) 
	
		{
			
		// Scanner Examples
		
		Scanner scanner = new Scanner(System.in);
		Scanner scanner2 = new Scanner(System.in);
		
		System.out.println("Please input a number");
		int temp =scanner.nextInt();
		System.out.println("your number is " + temp);
		
		System.out.println("Please input a string");
		String input =scanner.next();
		System.out.println("Your string is :" + input);
		
		System.out.println("Please input a sentence");
		String sc =scanner2.nextLine();
		System.out.println("Your sentence is :" + sc);
		
		
		// For loop example
		
		for(int i =0; i < 10; i++)
			{
				System.out.println("For Counter is :" + i);
			}
		
		
		// while loop example

		int i =0;
		while(i< 10)
		{
			
			System.out.println("While Counter is :" + i);
			i++;
			
		}
		
		// do-while example
		
		i=10;
		
		do
		{
			
			System.out.println("DoWhile Counter is :" + i);
			i++;
			
		} while(i <10);
		
	
		
		// byte and short type casting example
		
		/** 277 in binary is '100010101', but it has 9 bits, 
		a 'byte' datatype can hold only 8 bits,
		so out of 9 bits, right most 8 bits are considered whose value is 21 **/
		
		byte byteValue = (byte) 277;
		
		System.out.println("byte value :" + byteValue); 
		
		short shortValue = (short) 330000;
		
		System.out.println("short value : " + shortValue);
		
		
		// for infinite loop and stopping it using 'if' and 'break'
		// for(::)
		// {System.out.println("hello");}
		for(int i1 =0; i1 > -1; i1++)
		{
			System.out.println("hello " + i1);
			if(i1==10)
			{
			break;
			}
		} 
		
		// if and else if example
		int id=5;
		
		if(id==1)
		{
			System.out.println("id is 1");
		}
		
		else if(id==2)
		{
			System.out.println("id is 2");
		}
		
		else if(id==5)
		{
			System.out.println("id is 5");
		}
		else
		{
			System.out.println("id is not available");
		}
		
		//switch example
		
		id = 1;
		switch (id) 
		{
		case 0:
			System.out.println("caseId is 0");
			break;
		case 1:
			System.out.println("caseId is 1");
			break;
		case 2:
			System.out.println("caseId is 2");
			break;
		case 3:
			System.out.println("caseId is 3");
			break;
		default:
			System.out.println("something else");

		}

		
		
		
		
	
	}
	
	

}

